#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <queue>
#include <cstdio>
#include <string>
#include <stack>
#include <set>
#define IOS ios::sync_with_stdio(false), cin.tie(0)
using namespace std;
typedef long long ll;

int main()
{
    IOS;
    ll w,n,m;
    while(cin>>w>>n>>m){
    ll k1=n/w;
    ll k2=m/w;
    ll mod1=n%w;
    ll mod2=m%w;
    ll x1,y1,x2,y2;
    if(k1&1){
        if(mod1==0){
            x1=k1;y1=w;
        }
        else {
            x1=k1+1;y1=w-mod1+1;
        }
    }
    else {
        if(mod1==0){
            x1=k1;y1=1;
        }
        else {
            x1=k1+1;y1=mod1;
        }
    }
    if(k2&1){
        if(mod2==0){
            x2=k2;y2=w;
        }
        else {
            x2=k2+1;y2=w-mod2+1;
        }
    }
    else {
        if(mod2==0){
            x2=k2;y2=1;
        }
        else {
            x2=k2+1;y2=mod2;
        }
    }
    cout<<abs(x1-x2)+abs(y1-y2)<<endl;    
    }
    getchar();
    getchar();
    return 0;
}
